<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../../inc/taglib.jsp"%>
<link rel="stylesheet" href="../../../statics/ztree/css/demo.css" type="text/css">
<link rel="stylesheet" href="../../../statics/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="../../../statics/ztree/js/jquery.ztree.core.js"></script>
<div class="pageHeader">
	<form id="pagerForm" onsubmit="return navTabSearch(this);" action="/system/organization/list" method="post">
		<!-- 分页表单参数 -->
		<%@include file="../..//inc/pageForm.jsp"%>
		<div class="searchBar">
			<table class="searchContent">
			</table>
		</div>
	</form>
</div>
<div class="pageContent">

	<div class="panelBar">
		<ul class="toolBar">
			<!-- 局部刷新 在a标签添加属性  target="ajax" 和添加 rel="所要刷新的位置"-->
			<li><a class="add" mask="true"
				href="system/organization/toParentInsert" rel="organizationBox"
				target="ajax"><span>添加父机构</span></a></li>
			<li><a class="add" mask="true"
				href="system/organization/toChildInsert" rel="organizationBox"
				target="ajax"><span>添加子机构</span></a></li>
			<li><a class="edit" mask="true"
				href="system/organization/toUpdate?id=" rel="update"><span>修改</span></a></li>
			<li><a  class="delete" mask="true"
				href="system/organization/delete?id="
				target="ajaxTodo"  title="确定要删除吗？" warn="请最小选择一条记录"
				><span>删除</span></a></li>
				

			<li><a class="giveRole" href="system/organization/toRole?id=" mask="true"
			 target="dialog"  target="ajaxTodo"
			  warn="请选择一条记录">角色授权</a></li>
			
		</ul>
	</div>

	<!-- 左布局 -->
	<div layoutH="146"
		style="float: left; display: block; overflow: auto; width: 240px; border: solid 1px #CCC; line-height: 21px; background: #fff">
		<!-- <ul class="tree treeFolder"> -->
		<ul id="treeDemo" class="ztree"></ul>
	</div>
	<!-- 右布局 -->
	<div id="organizationBox" class="unitBox" style="margin-left: 246px;"></div>
</div>

<script type="text/javascript">
		
		var setting = {
			data: {
				simpleData: {
					enable: true
				}
			},
			callback: {
				
				onClick: onClick
			}
		};

		var zNodes =${requestScope.ztreeBeans};

		var tid=null;
		
		function onClick(event, treeId, treeNode) {
			/* console.log(treeNode);
			alert(treeNode.id); */
			tid=treeNode.id;
		}
		
		$(document).ready(function(){
			$.fn.zTree.init($("#treeDemo"), setting, zNodes);
			
			$(".edit").click(function(){
				if(tid!=null){
					$("#organizationBox").loadUrl($(this).attr("href")+tid,null,null);
				}else{
					alertMsg.warn('请选在1个节点再提交，请检查后重新提交！');
				}
				
				return false;
			});
			
			
			
			
			$(".delete").click(function(){
				 
				 if(tid!=null){
					 $(this).attr("href","system/organization/delete?id="+tid);
					}else{
						alertMsg.warn('请选在1个节点再提交，请检查后重新提交！');
					}
				 return false;
				
			});
			
			$(".giveRole").click(function(){
				 
				 if(tid!=null){
					 $(this).attr("href","system/organization/toRole?id="+tid);
					}else{
						alertMsg.warn('请选在1个节点再提交，请检查后重新提交！');
					}
				
				 return false;
			});
			
			
		/* 	$(".delete").click(function(){
				
				if(tid!=null){
					$("#treeDemo").loadUrl($(this).attr("href")+tid,null,null);
				}else{
					alertMsg.warn('请选在1个节点再删除！');
				}
				
				return false;
				
			}); */
			
			
		});
		
</script>

